You are here: Symbol Reference > Dew Namespace > Dew.Stats Namespace > Dew.Stats.Units Namespace > Classes > Statistics Class > Statistics Methods > PCA Method > Statistics.PCA Method ([In] TMtx, [In] TMtx, [In] TMtx, [In] TVec, [In] TVec, [In] TPCAMode)
Dew Stats for .NET
ContentsIndexHome
PreviousUpNext
Statistics.PCA Method ([In] TMtx, [In] TMtx, [In] TMtx, [In] TVec, [In] TVec, [In] TPCAMode)

Perform a PCA on Data matrix, where Data columns are variables and rows are the observables.

Syntax
C#
Visual Basic
public static void PCA([In] TMtx Data, [In] TMtx PC, [In] TMtx ZScores, [In] TVec EigenVec, [In] TVec VarPct, [In] TPCAMode PCAMode);

The (optional) PCAMode parameter defines whether the analysis should be run on correlation or covariance matrix. PCA procedure returns the principal components in matrix PC, the Z-scores (data, transformed in the PC space) in ZScores, the eigenvalues of the covariance matrix (variances) in the EigenVec vector and (optional) the percentage of total variance in VarPct vector. The PC, ZScores, EigenVec and VarPct dimensions are adjusted automatically.

In this example we derive the covariance matrix from original data and get the same results as in first example.

using Dew.Math; using Dew.Stat.Units; namespace Dew.Examples { private void Example() { Matrix data = new Matrix(0, 0); Matrix PC = new Matrix(0, 0); Matrix Z = new Matrix(0, 0); Vector variances = new Vector(0); Vector varPercent = new Vector(0); data.SetIt(2, 4, false, new double[] {1,3,5,2, 2,5,7,9}); Statistics.PCA(data, PC, Z, variances, varPercent, TPCAMode.PCACovMat); //works on raw data // ... variances = [29,0,0,0] // varPercent = [100,0,0,0] } }
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!